﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections.ObjectModel;

using MyLiveMesh;
using System.Threading;

namespace MyLiveMesh.ViewModels
{
    public class MainPage : INotifyPropertyChanged
    {
        private ReadOnlyObservableCollection<Models.Language> _languageItems;
        private string _selectedLanguage;

        public event PropertyChangedEventHandler PropertyChanged;

        public MainPage()
        {
            ObservableCollection<Models.Language> list = new ObservableCollection<Models.Language>();

            list.Add(new Models.Language("en-GB", "English", "English"));
            list.Add(new Models.Language("fr-FR", "Français", "French"));

            _languageItems = new ReadOnlyObservableCollection<Models.Language>(list);
            _selectedLanguage = Thread.CurrentThread.CurrentUICulture.Name;
        }

        public ReadOnlyObservableCollection<Models.Language> Languages
        {
            get { return _languageItems; }
        }

        public string Language
        {
            get { return _selectedLanguage; }
            set
            {
                if (_selectedLanguage != value)
                {
                    _selectedLanguage = value;
                    OnLanguageChanged(value);
                    OnPropertyChanged("Language");
                }
            }
        }

        private void OnLanguageChanged(string value)
        {
            ;
        }

        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        
    }
}
